/*
 * Copyright (c) 2009. Silenus Consultoria, S.L.
 */
package es.silenus.detecta.dao;

import java.util.Collection;


/**
 * Read-write generic DAO interface.
 *
 * @author <a href="mailto:malonso@silenus-consultoria.es">Mariano Alonso</a>
 * @since 22-mar-2009 11:04:13
 */
public interface ReadWriteDAO<T, K> extends ReadDAO<T, K> {
	/**
	 * Saves a detached object.
	 *
	 * @param object the object.
	 *
	 * @return the generated identifier.
	 */
	public K save(final T object);

	/**
	 * Updates a persistent object.
	 *
	 * @param object the object.
	 *
	 * @return the updated object.
	 */
	public T update(final T object);

	/**
	 * Removes a persistent object.
	 *
	 * @param object the persistent object.
	 */
	public void remove(final T object);

	/**
	 * Removes some persistent objects.
	 *
	 * @param objects the persistent objects.
	 */
	public void remove(final T[] objects);

	/**
	 * Removes some persistent objects.
	 *
	 * @param objects the persistent objects.
	 */
	public void remove(final Collection<T> objects);

	/**
	 * Removes a persistent object by its key.
	 *
	 * @param key the persistent object key.
	 */
	public void removeByKey(final K key);

	/**
	 * Removes some persistent objects by their keys.
	 *
	 * @param keys the persistent object keys.
	 */
	public void removeByKey(final K[] keys);

	/**
	 * Removes some persistent objects by their keys.
	 *
	 * @param keys the persistent object keys.
	 */
	public void removeByKey(final Collection<K> keys);
}
